package com.tanhua.server.controller;


import com.tanhua.domain.db.SoulAnswer;
import com.tanhua.server.service.SoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/testSoul")
public class SoulController {
    @Autowired
    private SoulService soulService;
    @GetMapping
    public  ResponseEntity<Object>  getSoulList(){
     ResponseEntity responseEntity= soulService.getSoulList();
     return responseEntity;
    }

    @PostMapping
    public  ResponseEntity<Object>  saveSoulList(@RequestBody HashMap<String,List<SoulAnswer>> answers){
        List<SoulAnswer> answers1 = answers.get("answers");
       ResponseEntity responseEntity= soulService.saveSoulList(answers1);
        return responseEntity;
    }

    @GetMapping("/report/{id}")
    public  ResponseEntity<Object>  getSoulList(@PathVariable("id") String id){
        ResponseEntity responseEntity= soulService.getReport(id);
        return responseEntity;
    }
}
